home *** CD-ROM | disk | FTP | other *** search
- /*
- * PrintPICTtoJPEG.c
-
- Authored by: David Gelphman 6/12/95.
-
- This application opens PICT data files and images them into a 32 bit deep
- offscreen bitmap. It then uses the offscreen bits as a source of bit image
- data to compress and print using QuickTime image compression.
-
- Copyright (c) Apple Computer Incorporated. All rights reserved.
-
- */
-
- #include "PrintPICTtoJPEG.h"
-
- /* globals */
-
- WindowPtr gTheWindow;
- PICTImage gThePICTImage;
- THPrint gPrinterRecord = NULL;
- GWorldPtr gTheOffscreenWorld;
- Boolean gDoImageCompression;
-
- /* main */
- SInt16 main()
- {
- OSErr theErr;
-
- // initialize the managers and the menus
- if (initMacintosh() != noErr)
- return 0;
-
- /* allocate a print record for us */
- gPrinterRecord = (THPrint)NewHandle(sizeof( TPrint ) );
-
- // Get the defaults for the current printer driver.
- if (gPrinterRecord != NULL && MemError() == noErr)
- {
- PrOpen();
- PrintDefault( gPrinterRecord );
- PrClose();
- }else{
- ParamText("\pCan't allocate Print Record.", "\p", "\p", "\p");
- Alert(kGenericError, NULL);
- return iMemFullErr;
- }
-
- // Check to see if there are any errors and report them if they occur.
- if(( theErr = PrError()) != noErr){
- Str255 scratchString;
- NumToString((long)theErr, scratchString);
- ParamText("\pCan't Do PrDefault for some reason.", scratchString, "\p", "\p");
- Alert(kGenericError, NULL);
- }
-
- // initialize our PICTImage Data Structure.
- gThePICTImage.theData = NULL;
- SetRect(&gThePICTImage.theBounds,0,0,0,0);
- gThePICTImage.theDesc = NULL;
-
- // Go ahead and get an image...
- DoTheOpenCommand();
-
- // Process events, etc.
- for (; handleEvent();)
- {
- } /* for */
- return 1;
-
- } /* main */
-
- //=====================================================================================
- // OSErr DrawBitImage(GWorldPtr theGWorld, Rect *bounds, Boolean doCompression)
- //=====================================================================================
- // Draws a Bitmap image from an offscreen GWorld.
- // If doCompression flag is true, then do compression, otherwise just do CopyBits.
- //=====================================================================================
-
- OSErr DrawBitImage(GWorldPtr theGWorld, Rect *bounds, Boolean doCompression)
- {
- OSErr theErr = noErr;
- Boolean canDraw;
- PixMapHandle sPixMap;
- Boolean didDrawing = false;
-
- sPixMap = GetGWorldPixMap(theGWorld);
-
- if(doCompression){
- MatrixRecord theMatrix;
- CQDProcs myStdProcs;
- StdPixProcPtr MyProcPtr;
- ImageDescriptionHandle theDescH;
- Handle compressedDataH = NULL;
- long maxCompressionSize = 0;
-
- // Lock the Pixels so we can draw from the PixMap
- canDraw = LockPixels(sPixMap);
-
- if((theErr == noErr) && canDraw){
- CodecType theCodecType = 'jpeg';
- CodecComponent theCodec = (CodecComponent)anyCodec;
- CodecQ spatialQuality = codecNormalQuality;
- short depth = 32;
-
- if(theErr == noErr)theErr = GetMaxCompressionSize(sPixMap, bounds, depth,
- spatialQuality, theCodecType,
- theCodec, &maxCompressionSize);
-
- if(theErr == noErr){
- // this allocation should be no problem
- theDescH = (ImageDescriptionHandle)NewHandle(sizeof(ImageDescriptionHandle));
-
- // this allocation is probably for a lot of memory
- compressedDataH = NewHandle(maxCompressionSize);
- theErr = MemError();
-
- // See if we allocated the ImageDescriptionHandle but
- // not the memory to receive the compressed image.
- if((theDescH != NULL) && (theErr != noErr)){
-
- // see if we can get temp memory instead
- // Since we are going to use the temp memory as a real handle
- // we require System 7.0 or greater
- compressedDataH = TempNewHandle(maxCompressionSize, &theErr);
- // this probably can't happen but just in case...
- if(compressedDataH == NULL && theErr == noErr)theErr = iMemFullErr;
- }
- }
-
- if((theErr == noErr) && (compressedDataH != NULL) && (theDescH != NULL)){
- MoveHHi(compressedDataH);
- HLock(compressedDataH);
-
- theErr = CompressImage(sPixMap, bounds, spatialQuality, theCodecType,
- theDescH, StripAddress(*compressedDataH));
- HUnlock(compressedDataH);
- }
-
- }
-
- // Unlock the pixels since we are done with them.
- UnlockPixels(sPixMap);
-
- if(theErr == noErr){
- // we need a pixmap for our call to the StdPix bottleneck.
- PixMapHandle SpecialPixMapH = NewPixMap();
- PixMapPtr SpecialPixMapP;
-
- if(SpecialPixMapH != NULL && MemError() == noErr){
-
- HLock((Handle)SpecialPixMapH);
- HLock(compressedDataH);
-
- SpecialPixMapP = (PixMapPtr)StripAddress(*(Handle)SpecialPixMapH);
-
- // This makes a compressed 'PixMap' structure into SpecialPixMap, using the
- // ImageDescription in 'theDescH' with the compressed image data in 'compressedDataH'
- theErr = SetCompressedPixMapInfo(SpecialPixMapP, theDescH, StripAddress(*compressedDataH), 0,NULL,NULL);
-
- // The data in compressedDataH needs to be locked during the StdPix proc call below.
- // We only unlock the data after we're done with the StdPix call.
-
- if(theErr == noErr){
- // set both flag bits described in IM QuickTime p.3-139 for StdPix
- short flags = kCallOldBits | kCallStdBits;
-
- // make a matrix which describes the mapping between the source
- // and destination rectangles. In our case, they will be the
- // same rectangle
- RectMatrix(&theMatrix, bounds, bounds);
-
- // Look to see if there are custom QuickDraw bottlenecks in the current port.
- if( (((CGrafPtr)qd.thePort)->grafProcs) == NULL){
- // Get the Standard Bottleneck procs.
- SetStdCProcs(&myStdProcs);
-
- // The 'newProc1' bottleneck is the 'StdPix' bottleneck.
- MyProcPtr = (StdPixProcPtr)myStdProcs.newProc1;
-
- }else{
- // Use the custom 'StdPix' bottleneck in the grafPort.
- MyProcPtr = (StdPixProcPtr)((CGrafPtr)qd.thePort)->grafProcs->newProc1;
- }
-
- // Call the bottleneck. The function call being used here is:
- // StdPix(SpecialPixMapP, &srcRect, &theMatrix, ditherCopy, NULL, NULL,NULL,flags)
- // with the appropriate StdPix bottleneck.
- CallStdPixProc(MyProcPtr,SpecialPixMapP, bounds, &theMatrix,
- ditherCopy, NULL, NULL,NULL,flags );
-
- didDrawing = true;
- }
- HUnlock(compressedDataH);
- HUnlock((Handle)SpecialPixMapH);
-
- }
- if(SpecialPixMapH)DisposePixMap(SpecialPixMapH);
- }
- if(compressedDataH)DisposeHandle(compressedDataH);
- if(theDescH)DisposeHandle((Handle)theDescH);
-
- }
-
- if(!didDrawing){
- /* backup in case:
- (1) we couldn't do drawing before because there wasn't enough memory to compress the data. OR
- (2) We were called without a request to do image compression. This is done here when we are
- not printing or we are printing to a grafPort which doesn't support color and therefore
- does not support the StdPix bottleneck.
- */
- canDraw = LockPixels(sPixMap);
- if(canDraw){
- OSErr qdErr;
- CopyBits( & (((GrafPtr)theGWorld)->portBits),
- & (((GrafPtr)qd.thePort)->portBits),
- bounds, bounds,
- ditherCopy, NULL);
- if( (qdErr = QDError()) != noErr){
- ParamText("\pNot Enough Memory To Handle this Image", "\p", "\p", "\p");
- Alert(kGenericError, NULL);
- }
- }
- UnlockPixels(sPixMap);
- }
- return theErr;
- } /* DrawBitImage */
-
-
-
-
- static void DoTheOpenCommand()
- {
- OSErr theErr = noErr;
- OSType theTypes[] = { 'PICT' };
- StandardFileReply theReply;
- Rect bounds;
- SInt16 windowTop = GetMBarHeight()+ 19;
- SInt16 right,bottom;
-
- // check to see if we already have data. If so, we'll dispose of it since we are going to open a new image.
- if( gThePICTImage.theData != NULL){
- DisposeHandle((Handle)gThePICTImage.theData);
- gThePICTImage.theData = NULL;
- }
-
- if(gTheOffscreenWorld != NULL){
- DisposeGWorld(gTheOffscreenWorld);
- gTheOffscreenWorld = NULL;
- }
-
- // disable the Print menu item since we can't print data anymore.
- DisableItem(GetMHandle(kFileMenuID), kPrintCommand);
-
- // Hide the existing window, if there is one.
- if(gTheWindow != NULL)HideWindow(gTheWindow);
-
- // Get a PICT file and read the data.
- if(theErr == noErr){
- StandardGetFile(NULL, 1, theTypes, &theReply);
- if (theReply.sfGood) {
- theErr = ReadPICTData(&(theReply.sfFile),(Handle *)&(gThePICTImage.theData) );
- if(theErr != noErr){
- ParamText("\pNot Enough Memory To Read this Image Into Memory.", "\p", "\p", "\p");
- Alert(kGenericError, NULL);
- }
- }else {
- // no file selected so just return.
- return;
- };
- };
-
- // Set the bounds field in the PICTData structure
- if (theErr == noErr) theErr = SetPICTBounds(&gThePICTImage);
-
- // Make an offscreen GWorld that is 32 bits deep and the size of the PICT bounding rect
- // Make sure the Pixels aren't purgeable so we can unload the PICT data after
- // we image the PICT into the offscreen buffer.
-
- if(theErr == noErr)theErr = NewGWorld(&gTheOffscreenWorld, 32, &gThePICTImage.theBounds,
- NULL, NULL,0); // flags are: pixels not purgeable and create a new device
-
- if(theErr == iMemFullErr) {
- ParamText("\pCan't Allocate the Offscreen GWorld.", "\p", "\p", "\p");
- Alert(kGenericError, NULL);
- }
-
- // Now make a Window of an appropriate size to hold our image. If we already
- // have a window then size it properly.
-
-
- // Max out the Window size at approximately the main screen size.
-
- if (theErr == noErr) {
- right = MIN(gThePICTImage.theBounds.right , qd.screenBits.bounds.right - kInsetBits );
- bottom = MIN(gThePICTImage.theBounds.bottom, qd.screenBits.bounds.bottom - (kInsetBits+windowTop) );
- SetRect(&bounds, 0 ,0 , right, bottom);
- }
-
- if (theErr == noErr){
-
- OffsetRect(&bounds, 0, windowTop);
-
- if(gTheWindow == NULL) {
- gTheWindow = NewCWindow(NULL, &bounds,
- (StringPtr)&(theReply.sfFile.name),
- false, noGrowDocProc, (WindowPtr)-1, true, 0);
- if (gTheWindow == NULL) {
- theErr = iMemFullErr;
- }
- } else{
- MoveWindow (gTheWindow, 0, windowTop, true);
- SetWTitle(gTheWindow, theReply.sfFile.name);
- SizeWindow (gTheWindow, bounds.right - bounds.left, bounds.bottom-bounds.top, true);
- }
- }
-
- if (theErr == noErr) {
- AlignWindow(gTheWindow, true, NULL, NULL);
- ShowWindow(gTheWindow);
- SetPort(gTheWindow);
- OffsetRect(&bounds, 0, -windowTop);
- ClipRect(&bounds);
- };
-
- // Now draw the PICT into the Offscreen Buffer.
- if( theErr == noErr){
- CGrafPtr saveCPort;
- GDHandle saveDevice;
- Boolean canDraw;
- PixMapHandle sPixMap;
-
- // save the existing Port and Device
- GetGWorld(&saveCPort, &saveDevice);
-
- // make the current drawing world our offscreen world
- SetGWorld(gTheOffscreenWorld,NULL);
-
- sPixMap = GetGWorldPixMap(gTheOffscreenWorld);
-
- // Lock the PixMap so we can draw.
- canDraw = LockPixels(sPixMap);
-
- // Only draw if the return result from LockPixels is true
- if(canDraw){
- EraseRect(&(gTheOffscreenWorld->portRect));
- DrawPicture(gThePICTImage.theData,&gThePICTImage.theBounds);
-
- // We don't need the PICT Data anymore so get rid of it.
- DisposeHandle((Handle)gThePICTImage.theData);
- gThePICTImage.theData = NULL;
-
- }
- // Unlock the Pixels now that we're done drawing
- UnlockPixels(sPixMap);
-
- // reset the saved Port and Device
- SetGWorld(saveCPort,saveDevice);
- }
-
- // Since we have an image, we'll enable the 'Print' menu item.
- if (theErr == noErr) EnableItem(GetMHandle(kFileMenuID), kPrintCommand);
-
- // Invalidate the Window contents so we'll get an update event.
- if( theErr == noErr)InvalRect(&gTheWindow->portRect);
-
- DrawMenuBar();
-
- } /* DoTheOpenCommand */
-
-
-
- // Initialize the World and check whether the appropriate managers are available.
- static OSErr initMacintosh()
- {
- long version;
- OSErr theErr = noErr;
-
- InitGraf(&qd.thePort);
- InitFonts();
- InitWindows();
- FlushEvents(everyEvent, 0);
- InitDialogs(NULL);
- TEInit();
- InitCursor();
- SetFractEnable(true); // I guess this urge comes from my old days at Adobe
-
- theErr = SetupMenus();
-
- if(theErr != noErr){
- ParamText("\pCouldn't load Menus.", "\p", "\p", "\p");
- }
-
- if(theErr == noErr){
- theErr = Gestalt(gestaltSystemVersion, &version);
- if( (theErr != noErr) || (version < 0x0700) ){
- ParamText("\pThis software requires System 7.0 or higher.", "\p", "\p", "\p");
- theErr = kAppError;
- }
- }
-
- if(theErr == noErr){
- theErr = Gestalt(gestaltQuickTimeVersion, &version);
- if( (theErr != noErr) ){
- ParamText("\pQuickTime not installed. This demo requires Quicktime.", "\p", "\p", "\p");
- }
- }
-
- if(theErr == noErr){
- theErr = Gestalt(gestaltCompressionMgr, &version);
- if( (theErr != noErr) ){
- ParamText("\pThe Image compression manager is not available. This can't continue!", "\p", "\p", "\p");
- }
- }
-
-
- if ( theErr == noErr) { // make sure there is a Codec available that can handle JPEG.
- CodecInfo theInfo;
-
- theErr = GetCodecInfo(&theInfo, 'jpeg', anyCodec);
- if(theErr != noErr)ParamText("\pThere don't appear to be any JPEG decompressors!", "\p", "\p", "\p");
- }
-
- if(theErr != noErr){
- Alert(kGenericError, NULL);
- }
-
- gTheOffscreenWorld = NULL;
-
- gDoImageCompression = true;
- CheckItem(GetMHandle(kImageCompressionMenuID), kDoImageCompression,gDoImageCompression);
-
- return theErr;
- } /* initMacintosh */
-
-
- static SInt16 handleEvent()
- {
- EventRecord e;
- WindowRecord *w;
- SInt32 s;
- Rect b;
- RgnHandle currentGrayRegion;
- OSErr theErr;
- GrafPtr oldPort;
-
- if (WaitNextEvent(everyEvent, &e, kSleepTime, 0L))
- {
- switch (e.what)
- {
- case mouseDown:
- switch (FindWindow(e.where, (WindowPtr *)&w))
- {
- case inContent:
- if ((WindowRecord *) FrontWindow() != w)
- SelectWindow((WindowPtr)w);
- else if (((WindowRecord *) w)->windowKind < 0)
- SystemClick(&e, (WindowPtr )w);
- break;
- case inDrag:
- currentGrayRegion = GetGrayRgn();
- b = (**(RgnHandle)currentGrayRegion).rgnBBox;
- // make sure drags align well for best performance.
- DragAlignedWindow((WindowPtr )w, e.where, &b, NULL, NULL);
- break;
- case inGoAway:
- if (TrackGoAway((WindowPtr )w, e.where)){
- HideWindow((WindowPtr )w);
- DisableItem(GetMHandle(kFileMenuID), kPrintCommand);
- DrawMenuBar();
- }
- break;
- case inGrow:
- SetRect(&b, 30, 30, 0x7fff, 0x7fff);
- s = GrowWindow((WindowPtr )w, e.where, &b);
- if (s){
- SizeWindow((WindowPtr )w, LoWord(s), HiWord(s), 1);
- SetPort((WindowPtr )w);
- InvalRect(&gTheWindow->portRect);
- }
- break;
- case inZoomIn:
- if (TrackBox((WindowPtr )w, e.where, inZoomIn)){
- ZoomWindow((WindowPtr )w, inZoomIn, 0);
- SetPort((WindowPtr )w);
- InvalRect(&gTheWindow->portRect);
- }
- break;
- case inZoomOut:
- if (TrackBox((WindowPtr )w, e.where, inZoomOut)){
- ZoomWindow((WindowPtr )w, inZoomOut, 0);
- SetPort((WindowPtr )w);
- InvalRect(&gTheWindow->portRect);
- }
- break;
- case inMenuBar:
- {
- SInt32 mResult = MenuSelect(e.where);
- SInt16 theMenu, theItem;
- theMenu = HiWord(mResult);
- theItem = LoWord(mResult);
- doCommand(theMenu, theItem);
- break;
- }
- }
- break;
- case updateEvt:
- if((WindowPtr)e.message == gTheWindow){
- BeginUpdate((WindowPtr)e.message);
-
- GetPort(&oldPort);
- SetPort((WindowPtr)e.message);
-
- theErr = DrawBitImage(gTheOffscreenWorld,&(gThePICTImage.theBounds),kNoCompression);
-
- SetPort(oldPort);
- EndUpdate((WindowPtr)e.message);
- }
- break;
- case keyDown:
- case autoKey:
- DoKeyDown(&e);
- break;
- default: break;
-
- } /* switch */
- } /* if */
- return 1;
- } /* handleEvent */
-
-
- static OSErr SetupMenus(void)
- {
- OSErr theErr = noErr;
- Handle MyMBar;
-
- MyMBar = GetNewMBar(128);
- if(MyMBar) {
- SetMenuBar(MyMBar);
- AddResMenu(GetMHandle(kAppleMenuID),'DRVR');
- DisableItem(GetMHandle(kFileMenuID), kPrintCommand);
-
- DrawMenuBar();
- } else {
- theErr = kCouldntLoadMenu;
- }
- return theErr;
- } /* SetupMenus */
-
-
- static void DoKeyDown(myEvent)
- EventRecord *myEvent;
- {
-
- unsigned char charCode = (unsigned char) (myEvent->message & charCodeMask);
-
- if (myEvent->modifiers & cmdKey)
- { /* command key */
- SInt32 mResult = MenuKey(charCode);
- SInt16 theMenu = HiWord(mResult); /* This is the resource ID */
- SInt16 theItem = LoWord(mResult);
- doCommand(theMenu, theItem);
- }
- return ;
- } /* DoKeyDown */
-
-
- /*
- Display the About dialog.
- */
- static void showAboutMeDialog()
- {
- GrafPtr savePort;
- SInt16 itemHit;
- DialogPtr theDialog;
-
- GetPort(&savePort);
- theDialog = GetNewDialog(kAboutMeDLOG, NULL, (WindowPtr) -1);
- SetPort(theDialog);
-
- do { ModalDialog(NULL, &itemHit); } while (itemHit != kOKButton);
-
- CloseDialog(theDialog);
-
- SetPort(savePort);
- return;
- } /* showAboutMeDialog */
-
-
- /*
- * Process Menu Selections
- */
- static void doCommand(SInt16 theMenu,SInt16 theItem)
- {
- OSErr theErr = noErr ;
-
- switch (theMenu)
- {
- case kAppleMenuID:
- if (theItem == kAboutMeCommand)
- {
- showAboutMeDialog();
- }
- else
- {
- GrafPtr savePort;
- Str255 daName;
- GetItem(GetMHandle(kAppleMenuID), theItem, daName);
- GetPort(&savePort);
- (void) OpenDeskAcc(daName);
- SetPort(savePort);
- }
- break;
-
- case kFileMenuID:
- switch (theItem)
- {
- case kOpenCommand:
- DoTheOpenCommand();
- break;
- case kSaveCommand:
- break;
- case kPageSetupCommand:
- PrOpen();
- theErr = PrError();
-
- if(theErr == noErr ){
- PrValidate( gPrinterRecord );
- theErr = PrError();
- }
-
- if(theErr == noErr){
- PrStlDialog(gPrinterRecord);
- theErr = PrError();
- }
- PrClose();
-
- if(theErr != noErr){
- Str255 scratchString;
- NumToString((long)theErr, scratchString);
- ParamText("\pThere was a print manager error.", scratchString, "\p", "\p");
- Alert(kGenericError, NULL);
- }
- break;
- case kPrintCommand:
- theErr = Print(gThePICTImage, gPrinterRecord);
- if(theErr != noErr){
- Str255 scratchString;
- NumToString((long)theErr, scratchString);
- ParamText("\pThere was an error during printing.", scratchString, "\p", "\p");
- Alert(kGenericError, NULL);
- }
- break;
- case kQuitCommand:
- ExitToShell();
- break;
- default:
- break;
- }
- break;
-
- case kEditMenuID:
- /*
- * Run this through SystemEdit first.
- * SystemEdit will return FALSE if it's not a system window.
- */
- if (SystemEdit(theItem-1)) break;
-
- case kImageCompressionMenuID:
- switch (theItem)
- {
- case kDoImageCompression:
- gDoImageCompression = !gDoImageCompression;
- CheckItem(GetMHandle(kImageCompressionMenuID), kDoImageCompression,gDoImageCompression);
- break;
- default:
- break;
- }
- break;
-
- default:
- break;
- } /*endswitch theMenu*/
-
- HiliteMenu(0);
- return;
- } /* DoCommand */
-
-
- static OSErr Print(PICTImage thePICTImage, THPrint thePrintRecord)
- {
- OSErr theDrawingErr = noErr;
- OSErr aPrintingErr = noErr;
-
- GrafPtr oldPort;
- TPrStatus thePrinterStatus;
- TPPrPort PrinterPort;
- Boolean OKToPrint;
-
- GetPort( &oldPort );
-
- PrOpen();
-
- if( PrError() == noErr){
- PrValidate(thePrintRecord);
- if( PrError() == noErr){
- OKToPrint = PrJobDialog(thePrintRecord);
- if(OKToPrint){
- PrinterPort = PrOpenDoc(thePrintRecord,NULL,NULL);
- if(PrError() == noErr){
- PrOpenPage(PrinterPort,NULL);
- if(PrError() == noErr){
- // Only do Compression if the Port is a Color Port
- theDrawingErr = DrawBitImage(gTheOffscreenWorld,&(thePICTImage.theBounds),
- ( gDoImageCompression && ISCOLORPORT((GrafPtr)PrinterPort)) );
- }
- PrClosePage(PrinterPort);
- }
- PrCloseDoc(PrinterPort);
- if(
- ( (*thePrintRecord)->prJob.bJDocLoop == bSpoolLoop ) &&
- ( PrError() == noErr )
- ){
- PrPicFile(thePrintRecord,NULL,NULL,NULL, &thePrinterStatus);
- }
- }
- }
- }
- aPrintingErr = PrError();
- PrClose();
- SetPort(oldPort);
- if(theDrawingErr != noErr) {
- Str255 scratchString;
- NumToString((long)theDrawingErr, scratchString);
- ParamText("\pCouldn't do compression.", scratchString, "\p", "\p");
- Alert(kGenericError, NULL);
- }
- return ( aPrintingErr) ;
- } /* Print */
-
-
- // Read the PICT data from the file into a Handle
- static OSErr ReadPICTData(FSSpec *theSpec, Handle *theData)
- {
- short refNum;
- OSErr theErr;
- long size;
-
- theErr = FSpOpenDF(theSpec, fsRdPerm, &refNum);
- if (theErr == noErr) {
- // position the file at the start
- theErr = SetFPos(refNum, fsFromStart, 0);
- // determine the total size of the file
- if(theErr == noErr)theErr = GetEOF(refNum, &size);
- if (theErr == noErr) {
- // skip PICT header
- size -= kPICTHeaderSize;
- theErr = SetFPos(refNum, fsFromStart, kPICTHeaderSize);
- }
- if (theErr == noErr) {
- if ((*theData = NewHandle(size)) && (MemError() == noErr) ) {
- HLock(*theData);
- theErr = FSRead(refNum, &size, **theData);
- HUnlock(*theData);
- } else theErr = memFullErr;
- }
- FSClose(refNum);
- }
- return theErr;
- }
-
- static OSErr SetPICTBounds(PICTImage *thePICTImage)
- {
- long theLen ;
- unsigned char *theData;
- short theCode;
- Rect *theBounds = &(*thePICTImage).theBounds;
-
- *theBounds = (*(*thePICTImage).theData)->picFrame;
- return noErr;
- } /* ReadPICTData */
-
-
-